package no.sachmuld.methodcombination.examples.reflection.extendbehaviour.v1;

import no.sachmuld.methodcombination.api.MethodInvocation;
import no.sachmuld.methodcombination.api.reflection.Default;
import no.sachmuld.methodcombination.api.BehaviourChain;

/**
 *
 */
public class Foo {

    private BehaviourChain<FooBehaviour> chain = new BehaviourChain<>();

    public Foo() {
        with(new FooBehaviour() {

            @Override
            public void foo(MethodInvocation<Void> methodInvocation) {
                System.out.println("Foo.foo");
            }

        });
    }

    final public void foo() {
        new Default<Void>().build(FooBehaviour.class, Foo.class, "foo").execute(this, chain);
    }

    final protected Foo with(FooBehaviour... behaviours) {
        chain.addAll(behaviours);
        return this;
    }

}
